package com.css.dzj.dzjwgr.common.audit.service.impl;

import com.css.dzj.dzjwgr.common.audit.service.SysAuditAsyncService;
import com.css.dzj.dzjwgr.common.audit.viewobjects.AuditFailVO;
import com.css.dzj.dzjwgr.common.audit.viewobjects.AuditSuccessVO;
import com.css.dzj.dzjwgr.common.util.JavaBeanUtil;
import com.css.dzj.dzjwgr.common.util.Restful.RestfulUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * 日志
 * @author zhouchanghe
 * @version 1.0.1
 * @date 2020.05.15
 */

@Service
@PropertySource(value = "classpath:base.properties")
public class SysAuditAsyncServiceImpl implements SysAuditAsyncService {
    @Autowired
    private HttpServletRequest request;
    @Value("${BASE_URL}")
    private String BASE_URL;
    @Override
    public void saveSuccessAudit(AuditSuccessVO auditSuccessVO) {
        String url = BASE_URL + "/platform/api/sys/audits/successaudit";
        HttpMethod method = HttpMethod.POST;
        Map map = new HashMap();
        try {
            map = JavaBeanUtil.convertBeanToMap(auditSuccessVO);
        }catch (Exception e){
            e.printStackTrace();
        }
        Map body = (Map) RestfulUtil.sendRestful(request, map, url, method).get("data");
    }

    @Override
    public void saveFailAudit(AuditFailVO auditFailVO) {
        String url = BASE_URL + "/platform/api/sys/audits/failaudit";
        HttpMethod method = HttpMethod.POST;
        Map map = new HashMap();
        try {
            map = JavaBeanUtil.convertBeanToMap(auditFailVO);
        }catch (Exception e){
            e.printStackTrace();
        }
        Map body = (Map) RestfulUtil.sendRestful(request, map, url, method).get("data");

    }


}


